package com.example.viewex;

import java.util.ArrayList;
import java.util.List;
import java.util.Vector;

import android.os.Bundle;
import android.app.Activity;
import android.app.ListActivity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

public class ListViewActivity extends Activity {

	ArrayAdapter<String> adapter;
	ListView lv;
	
	String[] list = {"어그레시브", "USD", "Razors", "Rollerblade", "Seba", "SSM", "USD", "Razors", "Rollerblade", "Seba", "SSM", "USD", "Razors", "Rollerblade", "Seba", "SSM"};
	List<String> mnt = new ArrayList<String>();
	List<String> river = new Vector<String>();

	
	
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_list_view);
		
		mnt.add("백두산");
		mnt.add("한라산");
		
		river.add("한탄강");
		river.add("소금강");
		
		
		// adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, list);

		// setListAdapter(adapter);
		
		/*ListView listview = (ListView) findViewById(R.id.listView1);
		listview.setAdapter(adapter);*/
		
		/*
		ListView listview = getListView();
		
		
		
		listview.setOnItemClickListener(new OnItemClickListener() {
			
			@Override
			public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
				Toast.makeText(getApplicationContext(), ((TextView) v).getText(), Toast.LENGTH_SHORT).show();
			}
		});*/
	}
	
	
	public void onClick(View v) {
		
		lv = (ListView)findViewById(R.id.listView1);
		
		
		switch(v.getId()){
		case R.id.button1:
			adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, list);
			break;
			
		case R.id.button2:
			adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, mnt);
			break;
			
		case R.id.button3:
			adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, river);
			break;
			
		case R.id.button4:
			adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, getResources().getStringArray(R.array.xmL));
			break;	
		}
		
		lv.setAdapter(adapter);
	}
	
	

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}

	
	@Override
	public boolean onOptionsItemSelected(MenuItem item) {

		new OptionMenu(this, item);
		
		return super.onOptionsItemSelected(item);
	}
}
